<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: CisCourse</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">CisCourse</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/app/models/cis_course_rb.html">
                app/models/cis_course.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                ActiveRecord::Base
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">



   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000053">dependencies_satisfied?</a>&nbsp;&nbsp;
      <a href="#M000051">iterate_users_semesters</a>&nbsp;&nbsp;
      <a href="#M000054">sections_for_semester</a>&nbsp;&nbsp;
      <a href="#M000052">to_s</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000053" class="method-detail">
        <a name="M000053"></a>

        <div class="method-heading">
          <a href="#M000053" class="method-signature">
          <span class="method-name">dependencies_satisfied?</span><span class="method-args">(semester_id, user_id)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
checks to make sure the course dependencies are satisfied for taking this
course in <tt>semester_id</tt> semester on <tt>user_id</tt>&#8216;s
schedule
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000053-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000053-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/cis_course.rb, line 37</span>
37:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">dependencies_satisfied?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user_id</span>)
38:     <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">semester_id</span> <span class="ruby-operator">==</span> <span class="ruby-value">-1</span>
39:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">true</span>
40:     <span class="ruby-keyword kw">end</span>
41:     
42:     <span class="ruby-identifier">user</span> = <span class="ruby-constant">User</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">user_id</span>)
43:    
44:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">course_dependency</span>.<span class="ruby-identifier">is_satisfied?</span>(<span class="ruby-identifier">semester_id</span>, <span class="ruby-identifier">user</span>)
45:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000051" class="method-detail">
        <a name="M000051"></a>

        <div class="method-heading">
          <a href="#M000051" class="method-signature">
          <span class="method-name">iterate_users_semesters</span><span class="method-args">(user) {|shared.id, friend, semester| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
iterator over all friends sharing this course for this user yields shared
course id, friend, and friend&#8216;s semester
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000051-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000051-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/cis_course.rb, line 12</span>
12:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">iterate_users_semesters</span>(<span class="ruby-identifier">user</span>)
13:     <span class="ruby-comment cmt">#find all relationship objects for this user id AND cis_course</span>
14:     
15:     <span class="ruby-identifier">shared_course_list</span> = <span class="ruby-identifier">shared_courses</span>.<span class="ruby-identifier">find</span> <span class="ruby-identifier">:all</span>, <span class="ruby-identifier">:include</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-value str">'relationship'</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> [<span class="ruby-value str">&quot;relationships.user_id = ?&quot;</span>, <span class="ruby-identifier">user</span>.<span class="ruby-identifier">id</span>]
16:     
17:     <span class="ruby-identifier">shared_course_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">shared</span><span class="ruby-operator">|</span>
18:       <span class="ruby-identifier">friend</span> = <span class="ruby-identifier">shared</span>.<span class="ruby-identifier">relationship</span>.<span class="ruby-identifier">friend</span>
19:       
20:       <span class="ruby-comment cmt">#fix for relationship which didn't get deleted properly</span>
21:       <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">friend</span>.<span class="ruby-identifier">nil?</span>
22:         <span class="ruby-identifier">semester</span> = <span class="ruby-constant">Semester</span>.<span class="ruby-identifier">find_by_sql</span> [<span class="ruby-value str">&quot;SELECT semesters.* FROM semesters LEFT OUTER JOIN cis_courses_semesters ON cis_courses_semesters.semester_id = semesters.id WHERE semesters.user_id = ? AND cis_courses_semesters.cis_course_id = ? LIMIT 1&quot;</span>, <span class="ruby-identifier">friend</span>.<span class="ruby-identifier">id</span>, <span class="ruby-identifier">id</span>]
23:       
24:         <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">shared</span>.<span class="ruby-identifier">id</span>, <span class="ruby-identifier">friend</span>, <span class="ruby-identifier">semester</span>
25:       <span class="ruby-keyword kw">end</span>
26:     <span class="ruby-keyword kw">end</span>
27:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000054" class="method-detail">
        <a name="M000054"></a>

        <div class="method-heading">
          <a href="#M000054" class="method-signature">
          <span class="method-name">sections_for_semester</span><span class="method-args">(semester)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
gets a list of sections for this course during the specified
<tt>semester</tt>
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000054-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000054-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/cis_course.rb, line 48</span>
48:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">sections_for_semester</span> <span class="ruby-identifier">semester</span>
49:     <span class="ruby-identifier">semesters</span> = <span class="ruby-identifier">cis_semesters</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>, <span class="ruby-identifier">:conditions</span> =<span class="ruby-operator">&gt;</span> {<span class="ruby-identifier">:semester</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">semester</span>.<span class="ruby-identifier">semester</span>, <span class="ruby-identifier">:year</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">semester</span>.<span class="ruby-identifier">year</span>})
50:     <span class="ruby-keyword kw">return</span> (<span class="ruby-identifier">semesters</span> <span class="ruby-keyword kw">and</span> <span class="ruby-identifier">semesters</span>.<span class="ruby-identifier">cis_sections</span>)
51:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000052" class="method-detail">
        <a name="M000052"></a>

        <div class="method-heading">
          <a href="#M000052" class="method-signature">
          <span class="method-name">to_s</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
to a string SUBJECT ###
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000052-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000052-source">
<pre>
    <span class="ruby-comment cmt"># File app/models/cis_course.rb, line 31</span>
31:   <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">to_s</span>
32:     <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">cis_subject</span>.<span class="ruby-identifier">to_s</span> <span class="ruby-operator">+</span> <span class="ruby-value str">' '</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">number</span>.<span class="ruby-identifier">to_s</span>
33:   <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>